package com.isoftstone.app.controller.alreadyPayment;

import com.isoftstone.bank.controller.base.BaseController;
import com.isoftstone.common.Tidings;
import com.isoftstone.merchant.entity.payment.Payment;
import com.isoftstone.merchant.service.payment.impl.PaymentServiceImpl;
import com.isoftstone.util.Const;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author: zhaojg
 * @Description
 * @Date: Created in 16:59 2017/12/9
 * @Modified by:
 * <p>
 * 已缴费查询接口
 */
@Controller
public class alreadyPaymentController extends BaseController {

    @Autowired
    PaymentServiceImpl paymentService;

    /**
     * @param openAccount 中银易商账号
     * @return 已缴费list
     */
    @RequestMapping(value = "app/admin/QueryAlreadyPayment", method = RequestMethod.POST)
    @ResponseBody
    public Tidings<Map<String, Object>> queryAlreadyPaymentList(String openAccount, String feeId, String beginDate, String endDate) {
        Tidings<Map<String, Object>> tidings = new Tidings<Map<String, Object>>();
        Map<String, Object> reMap = new HashMap<String, Object>();
        List<Payment> paymentList = null;
        try {
            if (StringUtils.isNotBlank(beginDate) && StringUtils.isNotBlank(endDate)) {
                paymentList = paymentService.queryAlreadyPaymentOpenAccount(openAccount, feeId, beginDate, endDate);
                reMap.put("paymentList", paymentList);
                tidings.setMsg("查询成功");
                tidings.setStatus(Const.SUCCESS);
                tidings.setT(reMap);
            }
        } catch (Exception e) {
            tidings.setMsg("查询失败");
            tidings.setStatus(Const.ERROR);
            e.printStackTrace();
        }
        return tidings;
    }


}
